// PersistentVisitor.h: interface for the PersistentVisitor class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_PERSISTENTVISITOR_H__59A99EA4_297C_4D58_95F7_2671DA8ABAC8__INCLUDED_)
#define AFX_PERSISTENTVISITOR_H__59A99EA4_297C_4D58_95F7_2671DA8ABAC8__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "PersistentObjectVisitor.h"
#include "Part.h"
#include "Volume.h"
#include "SupportHanger.h"
#include "Joint.h"

class Project;
namespace PersistentObjectOperation
{
	class DllExport PersistentVisitor: public PersistentObjectVisitor,
									   public VolumeVisitor,
									   public PartVisitor,
									   public JointVisitor,
									   public SHVisitor
	{
		UE_DECLARE_DYNAMIC(PersistentVisitor);
	public:
		PersistentVisitor();
		virtual ~PersistentVisitor();
		

	protected:
		typedef CArray<Part*, Part*> Parts;
		typedef CArray<Volume*, Volume*> Volumes;
		typedef CArray<Joint*, Joint*> Joints;
		typedef CArray<SupportHanger*, SupportHanger*> SupportHangers;

	public:
		virtual BOOL Visit(Volume*& pVolume);
		virtual BOOL Visit(Part*& pPart);
		virtual BOOL Visit(SupportHanger*& pSH);
		virtual BOOL Visit(Joint*& pJoint);

		virtual void StartPersistent(){
			m_theParts.RemoveAll();
			m_theJoints.RemoveAll();
			m_theVolumes.RemoveAll();
			m_theSHs.RemoveAll();
			m_bHasModelElement = FALSE;
		}

		virtual void EndPersistent(){
		}
	protected:
		const _ConnectionPtr& ProjectConnection(Project* pCurPrj);
		BOOL PersistentExecute(const CString& strSql, Project* pCurPrj);
		BOOL PersistentSH(SupportHanger* pSH);
		BOOL PersistentJoint(Joint* pJoint);
		BOOL PersistentPart(Part* pPart);
		void GetAttachOfModel(ModelObject* pObj);

	protected:
		Parts m_theParts;
		Volumes m_theVolumes;
		Joints m_theJoints;
		SupportHangers m_theSHs;
		BOOL m_bHasModelElement;
	};
}
#endif // !defined(AFX_PERSISTENTVISITOR_H__59A99EA4_297C_4D58_95F7_2671DA8ABAC8__INCLUDED_)
